package Study.Study;

public class TryDemo {
    public static void main(String[] args) {
        try {
            testThree();
        }catch (Exception e2){
            System.out.println(e2.getMessage());
//            Throwable e1 = e2.getCause();
//            System.out.println(e1.getMessage());
//            Throwable e =e1.getCause();
//            System.out.println(e.getMessage());
        }
    }
    public static void testOne() throws MyException{
        System.out.println("testOne");
        throw new MyException("输出第一个异常");
    }

    public static void testTwo() throws Exception {
        System.out.println("testTwo");
        try {
            testOne();
        }catch (Exception e){
            System.out.println(e.getMessage());
            Exception e1 = new Exception("新的异常2");
            throw e1;
        }
    }

    public static void testThree() throws Exception{
        System.out.println("testThree");
        try {
            testTwo();
        }catch (Exception e1){
            Exception e2 = new Exception("新的异常3");
            throw e2;
        }
    }
}

class MyException extends Exception{
    public MyException(String masssage){
        super(masssage);
    }
}